package com.yzion.baselib.widget.toast

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.widget.TextView
import com.yzion.baselib.R
import com.yzion.baselib.toast.IToast

/**
 * ZJJ
 * 默认样式的Toast
 * 实现自定义Toast可继承接口IToast，然后在App中的createToastView实现全局初始化，注意：App需继承BaseApp
 */
open class DefaultToast(context: Context) : IToast {
    var text: TextView
    var v: View = LayoutInflater.from(context).inflate(getLayoutId(), null)

    init {
        text = v.findViewById(R.id.tv_content)
    }

    open fun getLayoutId(): Int {
        return R.layout.by_toast
    }

    override fun setMsgText(msg: String?) {
        text.text = msg
    }

    override fun getView(): View {
        return v
    }
}